﻿using Core.SimpleTemp.Common;
using Core.SimpleTemp.Common.PagingQuery;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories;
using Core.Toolkit.Common;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Core.Toolkit.Core.Application;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Core.SimpleTemp.Application.CBS.dto;
using Core.SimpleTemp.Entitys.CBS;
using Core.SimpleTemp.Repositories.CBS;

namespace Core.SimpleTemp.Application.CBS
{
    public class CBS_UserAttachmentAppService : BaseAppService<CBS_UserAttachmentDto, CBS_UserAttachment, CBS_UserAttachmentRepository>
    {
        readonly ExcelHelp _excelHelp;
        public CBS_UserAttachmentAppService(CBS_UserAttachmentRepository repository, ExcelHelp excelHelp) : base(repository)
        {
            _excelHelp = excelHelp;
        }


        private LoadPageOffsetModelAuto<CBS_UserAttachment, CBS_UserAttachmentDto>
    GetLoadPageOffsetMode(PagingModel<CBS_UserAttachmentDto>
        pagingQueryModel)
        {
            var loadPageOffsetModel = this.GetLoadPageOffsetModelAuto(pagingQueryModel);
            var baseQuery = _repository.QueryBase().AsNoTracking();
            loadPageOffsetModel.BasqQuery = baseQuery;
            loadPageOffsetModel.Order = orderModel => orderModel.CreateTime;
            loadPageOffsetModel.Selector = model => new CBS_ListAttachment()
            {
                Id = model.Id,
            };
            return loadPageOffsetModel;
        }

        public async Task<IPageModel<CBS_UserAttachmentDto>> GetList(PagingModel<CBS_UserAttachmentDto>
    pagingQueryModel)
        {
            var loadPageOffsetModel = GetLoadPageOffsetMode(pagingQueryModel);
            return await base.LoadPageOffsetAsync(loadPageOffsetModel);
        }
    }
}
